﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using ebay.Dal.CenterDB_SystemTableAdapters;

namespace ebay.Dal
{
    public class SystemPara
    {
        public bool UpdatePara(string OrderTime, string OrderInterVal, string FeeTime, string FeeInterVal, string ActiveTime, string ActiveInterVal)
        {
            using (SqlConnection connection = new SqlConnection(SqlHelper.ceterDB_Conn))
            {
                connection.Open();
                T_SystemParasTableAdapter sysAdapter = new T_SystemParasTableAdapter();
                sysAdapter.Connection = connection;
                using (SqlTransaction trans = connection.BeginTransaction())
                {
                    sysAdapter.Transaction = trans;
                    try
                    {
                        sysAdapter.Update(OrderTime, "DownLoad", "OrderDownLoadTime");
                        sysAdapter.Update(OrderInterVal, "DownLoad", "OrderDownLoadInterVal");
                        sysAdapter.Update(FeeTime, "DownLoad", "EbayFeeDownLoadTime");
                        sysAdapter.Update(FeeInterVal, "DownLoad", "EbayFeeDownLoadInterVal");
                        sysAdapter.Update(ActiveTime, "DownLoad", "ActiveListDownLoadTime");
                        sysAdapter.Update(ActiveInterVal, "DownLoad", "ActiveListDownLoadInterVal");
                        trans.Commit();
                        return true;
                    }
                    catch {
                        trans.Rollback();
                        return false;
                    }
                }
            }
        }
    }
}
